/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hibernatedaos;

import hibentities.Product;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

/**
 *
 * @author piotrek
 */
@Repository
public class ProductHibernateDao {

	private SessionFactory sessionFactory;
	private HibernateTemplate hibernateTemplate;

	public ProductHibernateDao(){

	}
	
	@Autowired
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
    }

	public Product getProduct( Long id ){

		return this.hibernateTemplate.get(Product.class, id);

	}

}
